<?= form_open('index.php/rmis/management/researchesAction')?>
<div class="col-xs-9">
	<table border=".5">
		<tr><th>TITLE</th>
		<th>TYPE</th>
		<th>DEPARTMENT</th>
		<th>AUTHORS</th>
		<th>REQUEST DATE</th>
		<th></th></tr>
		<?php 

			if(isset($msg)){
				echo "<tr><td colspan = \"6\">".$msg."</td></tr>";
			}
			else {
				$i = 0;
				foreach ($res as $r) {
					echo "<tr><td>".ucwords($r['Title'])."</td>";
					echo "<td>";
					if($r['Type'] == 1)
						echo "Undergraduate";
					else
						echo "Graduate";
					echo "</td><td>";
					switch ($r['Dept']) {
						case 'CS':
							echo "COMPUTER SCIENCE";
							break;
						case 'IT':
							echo "INFORMATION TECHNOLOGY";
							break;
						case 'IS':
							echo "INFORMATION SCIENCE";
							break;
					}
					echo "</td><td>";
					foreach ($auth[$i] as $a) {
						echo $a['Name']." ";
					}
					$i++;
					if($stat == "validate upload"){
						echo "</td><td>".date("M d, Y ga",strtotime($r['Uploaded']))."</td><td>";
						echo "<button name='AUploaded' type='submit' 
							value='".$r['RID']."' 
							onclick='return confirm(\"Are you sure you want to validate this uploaded research?\")'>
							Accept</button>";
						echo " <button name='RUploaded' type='submit' 
							value='".$r['RID']."' 
							onclick='return confirm(\"Are you sure you want to reject this uploaded research?\")'>
							Reject</button></td>";
					}
					else {
						echo "</td><td>".date("M d, Y ga",strtotime($r['Uploaded']))."</td><td>";
						echo "<button name='AModified' type='submit' 
							value='".$r['RID']."' 
							onclick='return confirm(\"Are you sure you want to validate the modification of this research?\")'>
							Accept</button>";
					}
				}
			}
		?>
	</table>
</div>
<?= form_close()?>